//
//  CAMoneyView.m
//  LNH
//
//  Created by twentylx on 2018/2/7.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAMoneyView.h"

@implementation CAMoneyView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    self.backgroundColor = [UIColor whiteColor];
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.headerView];
    [self.headerView addSubview:self.leftLineView];
    [self.headerView addSubview:self.titleLabel];
    [self.headerView addSubview:self.rightLineView];
    
    [self addSubview:self.dayMoneyLabel];
    [self addSubview:self.dayLabel];
    [self addSubview:self.monthMoneyLabel];
    [self addSubview:self.monthLabel];
    [self addSubview:self.aboutMoneyLabel];
    [self addSubview:self.aboutLabel];
    [self addSubview:self.cashMoneyLabel];
    [self addSubview:self.cashLabel];
}

#pragma mark layout
- (void)updateConstraints {
    [super updateConstraints];
    
    [_headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self).offset(20);
        make.height.mas_equalTo(25);
    }];
    
    [_leftLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.headerView);
        make.right.equalTo(self.titleLabel.mas_left).offset(-10);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.headerView);
        make.width.mas_equalTo(80);
    }];
    
    [_rightLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.headerView);
        make.left.equalTo(self.titleLabel.mas_right).offset(10);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
    
    [_dayMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(20);
        make.top.equalTo(self.headerView.mas_bottom).offset(20);
        make.width.mas_equalTo((SCREEN_WIDTH - 100)/4);
    }];
    
    [_dayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dayMoneyLabel);
        make.top.equalTo(self.dayMoneyLabel.mas_bottom).offset(5);
        make.width.mas_equalTo((SCREEN_WIDTH - 100)/4);
    }];
    
    [_monthMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dayMoneyLabel.mas_right).offset(20);
        make.top.equalTo(self.headerView.mas_bottom).offset(20);
        make.width.mas_equalTo((SCREEN_WIDTH - 100)/4);
    }];
    
    [_monthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.monthMoneyLabel);
        make.top.equalTo(self.monthMoneyLabel.mas_bottom).offset(5);
        make.width.mas_equalTo((SCREEN_WIDTH - 100)/4);
    }];
    
    [_aboutMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.monthMoneyLabel.mas_right).offset(20);
        make.top.equalTo(self.headerView.mas_bottom).offset(20);
        make.width.mas_equalTo((SCREEN_WIDTH - 100)/4);
    }];
    
    [_aboutLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.aboutMoneyLabel);
        make.top.equalTo(self.aboutMoneyLabel.mas_bottom).offset(5);
        make.width.mas_equalTo((SCREEN_WIDTH - 100)/4);
    }];
    
    [_cashMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.aboutMoneyLabel.mas_right).offset(20);
        make.top.equalTo(self.headerView.mas_bottom).offset(20);
        make.width.mas_equalTo((SCREEN_WIDTH - 100)/4);
    }];
    
    [_cashLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.cashMoneyLabel);
        make.top.equalTo(self.cashMoneyLabel.mas_bottom).offset(5);
        make.width.mas_equalTo((SCREEN_WIDTH - 100)/4);
    }];
}

#pragma mark get & set
- (UIView *)headerView {
    if (!_headerView) {
        _headerView = [UIView new];
        _headerView.backgroundColor = RGBCOLOR(233, 85, 19);
    }
    return _headerView;
}

- (UIView *)leftLineView {
    if (!_leftLineView) {
        _leftLineView = [UIView new];
        _leftLineView.backgroundColor = RGBCOLOR(245, 174, 143);
    }
    return _leftLineView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"我的收入";
        _titleLabel.font = [UIFont systemFontOfSize:18];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.textColor = [UIColor whiteColor];
    }
    return _titleLabel;
}

- (UIView *)rightLineView {
    if (!_rightLineView) {
        _rightLineView = [UIView new];
        _rightLineView.backgroundColor = RGBCOLOR(245, 174, 143);
    }
    return _rightLineView;
}

- (UILabel *)dayMoneyLabel {
    if (!_dayMoneyLabel) {
        _dayMoneyLabel = [UILabel new];
        _dayMoneyLabel.text = @"0.00";
        _dayMoneyLabel.font = [UIFont systemFontOfSize:16];
        _dayMoneyLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _dayMoneyLabel;
}

- (UILabel *)dayLabel {
    if (!_dayLabel) {
        _dayLabel = [UILabel new];
        _dayLabel.text = @"今日预估收入";
        _dayLabel.font = [UIFont systemFontOfSize:16];
        _dayLabel.textColor = RGBCOLOR(158, 158, 158);
        _dayLabel.numberOfLines = 2;
        _dayLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _dayLabel;
}

- (UILabel *)monthMoneyLabel {
    if (!_monthMoneyLabel) {
        _monthMoneyLabel = [UILabel new];
        _monthMoneyLabel.text = @"0.00";
        _monthMoneyLabel.font = [UIFont systemFontOfSize:16];
        _monthMoneyLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _monthMoneyLabel;
}

- (UILabel *)monthLabel {
    if (!_monthLabel) {
        _monthLabel = [UILabel new];
        _monthLabel.text = @"本月预估收入";
        _monthLabel.font = [UIFont systemFontOfSize:16];
        _monthLabel.textColor = RGBCOLOR(158, 158, 158);
        _monthLabel.numberOfLines = 2;
        _monthLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _monthLabel;
}

- (UILabel *)aboutMoneyLabel {
    if (!_aboutMoneyLabel) {
        _aboutMoneyLabel = [UILabel new];
        _aboutMoneyLabel.text = @"0.00";
        _aboutMoneyLabel.font = [UIFont systemFontOfSize:16];
        _aboutMoneyLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _aboutMoneyLabel;
}

- (UILabel *)aboutLabel {
    if (!_aboutLabel) {
        _aboutLabel = [UILabel new];
        _aboutLabel.text = @"累计预估收入";
        _aboutLabel.font = [UIFont systemFontOfSize:16];
        _aboutLabel.textColor = RGBCOLOR(158, 158, 158);
        _aboutLabel.numberOfLines = 2;
        _aboutLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _aboutLabel;
}

- (UILabel *)cashMoneyLabel {
    if (!_cashMoneyLabel) {
        _cashMoneyLabel = [UILabel new];
        _cashMoneyLabel.text = @"0.00";
        _cashMoneyLabel.font = [UIFont systemFontOfSize:16];
        _cashMoneyLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _cashMoneyLabel;
}

- (UILabel *)cashLabel {
    if (!_cashLabel) {
        _cashLabel = [UILabel new];
        _cashLabel.text = @"可提现金额";
        _cashLabel.font = [UIFont systemFontOfSize:16];
        _cashLabel.textColor = RGBCOLOR(158, 158, 158);
        _cashLabel.numberOfLines = 2;
        _cashLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _cashLabel;
}

@end
